/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.hanze.shoestring.domain;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alex
 */
@Entity
@Table(name = "reis")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Reis.findAll", query = "SELECT r FROM Reis r"),
    @NamedQuery(name = "Reis.findById", query = "SELECT r FROM Reis r WHERE r.id = :id"),
    @NamedQuery(name = "Reis.findByDuur", query = "SELECT r FROM Reis r WHERE r.duur = :duur"),
    @NamedQuery(name = "Reis.findByVerlenging", query = "SELECT r FROM Reis r WHERE r.verlenging = :verlenging")})
public class Reis implements Serializable, Comparable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "duur")
    private int duur;
    @Basic(optional = false)
    @NotNull
    @Column(name = "verlenging")
    private boolean verlenging;
    @Lob
    @Size(max = 65535)
    @Column(name = "omschrijving")
    private String omschrijving;
    @Column(name = "naam")
    private String naam;
    @Column (name = "afbeelding")
    private String afbeelding;
    
    @JoinColumn(name = "reistype_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Reistype reistypeId;
    @JoinColumn(name = "land_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Land landId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "reisId")
    private List<Planning> planningList;

    public Reis() {
    }

    public Reis(Integer id) {
        this.id = id;
    }

    public Reis(Integer id, int duur, boolean verlenging) {
        this.id = id;
        this.duur = duur;
        this.verlenging = verlenging;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getDuur() {
        return duur;
    }

    public void setDuur(int duur) {
        this.duur = duur;
    }

    public boolean getVerlenging() {
        return verlenging;
    }

    public void setVerlenging(boolean verlenging) {
        this.verlenging = verlenging;
    }

    public String getOmschrijving() {
        return omschrijving;
    }

    public void setOmschrijving(String omschrijving) {
        this.omschrijving = omschrijving;
    }

    public String getNaam() {
        return naam;
    }

    public void setNaam(String naam) {
        this.naam = naam;
    }

    public String getAfbeelding() {
        return afbeelding;
    }

    public void setAfbeelding(String afbeelding) {
        this.afbeelding = afbeelding;
    }
    
    public Reistype getReistypeId() {
        return reistypeId;
    }

    public void setReistypeId(Reistype reistypeId) {
        this.reistypeId = reistypeId;
    }

    public Land getLandId() {
        return landId;
    }

    public void setLandId(Land landId) {
        this.landId = landId;
    }

    @XmlTransient
    public List<Planning> getPlanningList() {
        return planningList;
    }

    public void setPlanningList(List<Planning> planningList) {
        this.planningList = planningList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reis)) {
            return false;
        }
        Reis other = (Reis) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getNaam();
    }

    @Override
    public int compareTo(Object o) {
        Reis other = (Reis) o;
        
        return this.getNaam().compareTo(other.getNaam());        
    }
    
}
